<?php


defined('JPATH_PLATFORM') or die;

// Initialise variables.
$buffer = null;
$lists = null;

// Get the message queue
$messages = JFactory::getApplication()->getMessageQueue();

if (count($messages)):
	// Build the sorted message list
	if (is_array($messages) && !empty($messages))
	{
		foreach ($messages as $msg)
		{
			if (isset($msg['type']) && isset($msg['message']))
			{
				$lists[$msg['type']][] = $msg['message'];
			}
		}
	}
	
	// If messages exist render them
	if (is_array($lists))
	{
		$buffer .= "\n<dl id=\"system-message\"><div id=\"form_manager_message\" class=\"serror serror1\"><div>";
		$buffer .= "\n\t<ul>";
		foreach ($lists as $type => $msgs)
		{
			if (count($msgs))
			{
				foreach ($msgs as $msg)
				{
					$buffer .= "\n\t\t<li>" . $msg . "</li>";
				}
					
			}
		}
	
	}
	$buffer .= "\n\t</ul>";
	$buffer .= "\n</div></div>\n</dl>";
	echo $buffer;
else: ?>
	<div id="system-message">
		<div id="form_manager_message" style="display: none; overflow: visible;" class="serror">
			<div>
				<ul id="message_content">
					
				</ul>
			</div>
		</div>
	</div>
 <?php endif;